package com.shardingsphere.modules.controller;

import com.shardingsphere.common.result.Result;
import com.shardingsphere.modules.entity.Student;
import com.shardingsphere.modules.entity.Teacher;
import com.shardingsphere.modules.service.StudentService;
import com.shardingsphere.modules.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = "首页模块")
@RestController
public class IndexController {

    @Resource
    private TeacherService teacherService;

    @Resource
    private StudentService studentService;

    @ApiOperation(value = "查询学生和老师信息")
    @GetMapping("/select")
    public Result<Object> select() {
        List<Teacher> teachers = teacherService.selectList();
        List<Student> students = studentService.selectList();

        Map<String, List> result = new HashMap<>();
        result.put("teachers", teachers);
        result.put("students", students);

        return Result.createBySuccess(result);
    }
}
